package com.group3.controller.adminController;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.group3.domain.GroupScores;
import com.group3.domain.PersonalScores;
import com.group3.pojo.Page;
import com.group3.pojo.result.GroupScoresResult;
import com.group3.pojo.result.PersonalScoresResult;
import com.group3.service.ACompositeScoresService;
import com.group3.utils.Result;
import io.swagger.annotations.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * AComprehensiveScore
 *
 * @author HY
 * 2021/06/04 11:59
 **/


@Api(tags = "管理员接口")
@RestController
@RequestMapping("/admin")
public class ACompositeScoresController {

    @Resource
    private ACompositeScoresService aCompositeScoresService;

    //查看个人得分
    @GetMapping(value = "/PersonalScores")
    @ApiOperation(value = "查看个人综合得分集合")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lessonName", value = "项目名称",
                    dataType = "String"),
            @ApiImplicitParam(name = "groupId", value = "小组id",
                    dataType = "Integer"),
            @ApiImplicitParam(name = "pageNumber", value = "页码",
                    dataType = "int"),
            @ApiImplicitParam(name = "pageSize", value = "每页数量",
                    dataType = "int")
    })
    public Result<List<PersonalScores>> selectCompositeScoresPersonal(
            @NotEmpty String lessonName, Integer groupId, @Validated Page page){

//        return ResultUtil.success(lessonName+groupId+page);
        return aCompositeScoresService.selectCompositeScoresPersonal(
                lessonName, groupId, page);
    }

    //查询个人得分详情
    @ApiOperation(value = "查询个人得分详情")
    @GetMapping(value = "/PersonalScores/resource")
    @ApiImplicitParams({
            //学生成绩与项目名绑定
            @ApiImplicitParam(name = "studentId", value = "学生id",
                    dataType = "String"),
            @ApiImplicitParam(name = "lessonName", value = "项目名称",
                    dataType = "String")
    })
    public Result<PersonalScoresResult> showStudentScore(
            @NotBlank String studentId, @NotBlank String lessonName) {

//        return ResultUtil.success(studentId+lessonName);
        return aCompositeScoresService.showStudentScore(
                studentId, lessonName);
    }

    //查看小组得分
    @GetMapping(value = "/GroupScores")
    @ApiOperation(value = "查看小组综合得分集合")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "lessonName", value = "项目名称",
//                    dataType = "String"),
//            @ApiImplicitParam(name = "groupId", value = "小组id",
//                    dataType = "Integer"),
//    })
    public Result<List<GroupScores>> selectCompositeScoresGroup(
            @NotEmpty String lessonName, @NotEmpty Integer groupId, @Validated Page page){

        return aCompositeScoresService.selectCompositeScoresGroup(
                lessonName, groupId, page);
    }

    //查询小组得分详情
    @ApiOperation(value = "查询小组得分详情")
    @GetMapping(value = "/GroupScores/resource")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "groupId", value = "小组id",
//                    dataType = "Integer"),
//            @ApiImplicitParam(name = "lessonName", value = "项目名称",
//                    dataType = "String"),
//    })
    public Result<List<GroupScoresResult>> showGroupScore(
            @NotEmpty Integer groupId, @NotEmpty String lessonName) {

        return aCompositeScoresService.showGroupScore(groupId, lessonName);
    }
}
